<?php
namespace app\log\model;
use app\common\model\Common;
use think\Db;
class PayLog extends Common
{
	protected $table = "mps_order_pay_log";
	protected $autoWriteTimestamp = true;
	protected $createTime = 'addtime';
    protected $updateTime = false;
    protected $append = ['pay_type_text'];


    /**
	 * 获取列表
	 * @param array $where 查询条件
	 * @param string $order 排序条件
	 * @param intger $page 当前页数
	 * @param intger $row 每页条数
	 * @param string $search 关键字检索条件
	 */
	public function listData($where, $order, $page, $row, $search = '')
	{
		if($row == 'limit'){
			$list = $this->where($search)->where($where)->order($order)->select();
		}else{
			$list = $this->where($search)->where($where)->order($order)->page($page, $row)->select();
		}
		
		foreach($list as $k => $v){
			$v->id = $k+1;
		}
		return $list;
	}

	/**
	 * 获取器
	 */
    public function getAddtimeAttr($value)
    {
    	return $value > 0 ? date('Y-m-d H:i:s',$value) : '----';
    }
    public function getPayTypeTextAttr($value,$data)
    {
    	switch($data['pay_type']){
    		case 0: return '现金支付';break;
    		case 1: return '手机支付';break;
    		case 2: return '银行卡支付';break;
    		default: return '异常';break;
    	}
    }
}